﻿using System.Collections.Generic;
using System.Linq;
using DailyPoetryX.Services;

namespace DailyPoetryX.Models {
    public class MenuItem {
        private MenuItem() {
        }

        public string Title { get; private set; }
        public string PageKey { get; private set; }

        public static IList<MenuItem> Items { get; } = new List<MenuItem> {
            new MenuItem {
                Title = "今日推荐",
                PageKey = RootNavigationServiceConstants.TodayPage
            },
            new MenuItem {
                Title = "诗词搜索",
                PageKey = RootNavigationServiceConstants.QueryPage
            },
            new MenuItem {
                Title = "我的收藏",
                PageKey = RootNavigationServiceConstants.FavoritePage
            },
            new MenuItem {
                Title = "数据同步",
                PageKey = RootNavigationServiceConstants.SyncPage
            },
            new MenuItem {
                Title = "关于", PageKey = RootNavigationServiceConstants.AboutPage
            }
        };

        private static Dictionary<string, MenuItem> ItemDictionary =
            Items.ToDictionary(p => p.PageKey, p => p);

        public static MenuItem GetMenuItem(string pageKey) =>
            ItemDictionary.ContainsKey(pageKey)
                ? ItemDictionary[pageKey]
                : null;
    }
}